/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.MessageManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Date;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListAllWhiteBoard extends AbstractAction
/*    */ {
/* 29 */   private static Logger logger = Logger.getLogger(ListAllWhiteBoard.class
/* 30 */     .getName());
/*    */ 
/*    */   public ListAllWhiteBoard(AbstractHttpServlet servlet)
/*    */   {
/* 33 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 39 */     String createUserId = Util.getURLParameter(request
/* 40 */       .getParameter("CreateUserId"));
/* 41 */     int offset = Util.getURLIntParameter(request.getParameter("Offset"));
/*    */ 
/* 43 */     int totalPages = Util.getURLIntParameter(request
/* 44 */       .getParameter("TotalPages"));
/*    */ 
/* 46 */     int readFlag = 
/* 47 */       Util.getURLIntParameter(request.getParameter("ReadFlag"));
/*    */ 
/* 49 */     Date startDate = Util.str2Date(request.getParameter("StartDate"));
/* 50 */     Date endDate = Util.str2Date(request.getParameter("EndDate"));
/*    */ 
/* 52 */     User loginUser = getLoginUser(request);
/*    */ 
/* 54 */     MessageManager manager = new MessageManager();
/*    */ 
/* 56 */     response.setContentType("text/html;charset=utf-8");
/* 57 */     PrintWriter out = response.getWriter();
/* 58 */     JSONObject jsonObject = new JSONObject();
/*    */     try
/*    */     {
/* 61 */       int totalNums = 0;
/* 62 */       if (totalPages < 1) {
/* 63 */         totalNums = manager.listAllCount(loginUser.userId, 
/* 64 */           createUserId, readFlag, startDate, endDate, 
/* 65 */           loginUser.companyId);
/* 66 */         totalPages = totalNums / 10;
/* 67 */         if (totalNums % 10 > 0) {
/* 68 */           totalPages++;
/*    */         }
/*    */       }
/* 71 */       if (totalPages > 0) {
/* 72 */         List result = manager.listAll(
/* 73 */           loginUser.userId, createUserId, readFlag, startDate, 
/* 74 */           endDate, offset, 10, loginUser.companyId);
/* 75 */         jsonObject.put("whiteboards", result);
/*    */       }
/* 77 */       jsonObject.put("error", "0");
/* 78 */       jsonObject.put("totalNums", Integer.valueOf(totalNums));
/* 79 */       jsonObject.put("totalPages", Integer.valueOf(totalPages));
/*    */     } catch (DBException e) {
/* 81 */       logger.warn("list all whiteboard failed", e);
/*    */     } catch (SQLException e) {
/* 83 */       logger.warn("list all whiteboard failed", e);
/*    */     }
/* 85 */     out.println(jsonObject);
/* 86 */     out.flush();
/* 87 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListAllWhiteBoard
 * JD-Core Version:    0.6.1
 */